/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;

/**
 *
 * @author James
 */
@Entity
public class ItemDetails implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private int  discount;     // percentage will be negative (e.g. -20 will be 20% discount), amount will be positive (e.g. 20 will be $20 discount)
    private int  price;        // Dollar + Cent * 100
    private int  redeemPrice;  // Amount of Loyalty points to redeem for the item
    private int  additionalLoyaltyPoint; // Amount of additional Loyalty point that partner wants to give for this item.
    private long startedDate;
    private long stoppedDate;
    @ManyToMany
    private List<Item> subItems; // This one is for creating packages consisting of smaller items
    
    public ItemDetails() {
        this.startedDate = System.currentTimeMillis();
        this.stoppedDate = 0;
        this.subItems    = null;
    }
    
    public void createItemDetails(int discount, int price, int redeemPrice, int additionalLoyaltyPoint, List<Item> subItems) {
        this.discount    = discount;
        this.price       = price;
        this.redeemPrice = redeemPrice;
        this.additionalLoyaltyPoint = additionalLoyaltyPoint;
        this.subItems    = subItems;
    }
    
    //Getters and Setters
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public int getAdditionalLoyaltyPoint() {
        return additionalLoyaltyPoint;
    }

    public void setAdditionalLoyaltyPoint(int additionalLoyaltyPoint) {
        this.additionalLoyaltyPoint = additionalLoyaltyPoint;
    }

    public int getDiscount() {
        return discount;
    }

    public void setDiscount(int discount) {
        this.discount = discount;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getRedeemPrice() {
        return redeemPrice;
    }

    public void setRedeemPrice(int redeemPrice) {
        this.redeemPrice = redeemPrice;
    }

    public long getStartedDate() {
        return startedDate;
    }

    public void setStartedDate(long startedDate) {
        this.startedDate = startedDate;
    }

    public long getStoppedDate() {
        return stoppedDate;
    }

    public void setStoppedDate(long stoppedDate) {
        this.stoppedDate = stoppedDate;
    }

    public List<Item> getSubItems() {
        return subItems;
    }

    public void setSubItems(List<Item> subItems) {
        this.subItems = subItems;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ItemDetails)) {
            return false;
        }
        ItemDetails other = (ItemDetails) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.ItemDetails[ id=" + id + " ]";
    }
    
}
